(function webpackUniversalModuleDefinition(root, factory) {
    if (typeof exports === 'object' && typeof module === 'object')
        module.exports = factory();
    else if (typeof define === 'function' && define.amd)
        define(factory);
    else if (typeof exports === 'object')
        exports["chains"] = factory();
    else
        root["chains"] = factory();
})(this, function () {
    const me = {

        chains: (...fs) => me.chains_with_global(null,...fs),

        chains_with_global: (realworld, ...fs) => {
            return fs.reduce((produce, f) => {
                return f(produce, realworld)
            }, null)
        },

        global: (realworld = {}) => {
            realworld = (typeof realworld == 'object') ? realworld : {}
            return {
                chains: (...fs) => {
                    return me.chains_with_global(realworld, ...fs)
                }
            }
        },

    }
    return me
})